<!DOCTYPE html>

<html>
<head>
  <title>charset_range.js</title>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <meta name="viewport" content="width=device-width, target-densitydpi=160dpi, initial-scale=1.0; maximum-scale=1.0; user-scalable=0;">
  <link rel="stylesheet" media="all" href="../../../docco.css" />
</head>
<body>
  <div id="container">
    <div id="background"></div>
    
    <ul class="sections">
        
          <li id="title">
              <div class="annotation">
                  <h1>charset_range.js</h1>
              </div>
          </li>
        
        
        
        <li id="section-1">
            <div class="annotation">
              
              <div class="pilwrap ">
                <a class="pilcrow" href="#section-1">&#182;</a>
              </div>
              <p>CharsetRange nodes are used for <code>[a-z]</code> regular expression syntax. The two
literal or escape nodes are rendered with a hyphen between them.</p>

            </div>
            
            <div class="content"><div class='highlight'><pre>
<span class="hljs-keyword">import</span> util <span class="hljs-keyword">from</span> <span class="hljs-string">'../../util.js'</span>;
<span class="hljs-keyword">import</span> _ <span class="hljs-keyword">from</span> <span class="hljs-string">'lodash'</span>;

<span class="hljs-keyword">export</span> <span class="hljs-keyword">default</span> {
  <span class="hljs-attr">type</span>: <span class="hljs-string">'charset-range'</span>,</pre></div></div>
            
        </li>
        
        
        <li id="section-2">
            <div class="annotation">
              
              <div class="pilwrap ">
                <a class="pilcrow" href="#section-2">&#182;</a>
              </div>
              <p>Renders the charset range into the currently set container</p>

            </div>
            
            <div class="content"><div class='highlight'><pre>  _render() {
    <span class="hljs-keyword">let</span> contents = [
      <span class="hljs-keyword">this</span>.first,
      <span class="hljs-keyword">this</span>.container.text(<span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-string">'-'</span>),
      <span class="hljs-keyword">this</span>.last
    ];</pre></div></div>
            
        </li>
        
        
        <li id="section-3">
            <div class="annotation">
              
              <div class="pilwrap ">
                <a class="pilcrow" href="#section-3">&#182;</a>
              </div>
              <p>Render the nodes of the range.</p>

            </div>
            
            <div class="content"><div class='highlight'><pre>    <span class="hljs-keyword">return</span> <span class="hljs-built_in">Promise</span>.all([
      <span class="hljs-keyword">this</span>.first.render(<span class="hljs-keyword">this</span>.container.group()),
      <span class="hljs-keyword">this</span>.last.render(<span class="hljs-keyword">this</span>.container.group())
    ])
      .then(<span class="hljs-function"><span class="hljs-params">()</span> =&gt;</span> {</pre></div></div>
            
        </li>
        
        
        <li id="section-4">
            <div class="annotation">
              
              <div class="pilwrap ">
                <a class="pilcrow" href="#section-4">&#182;</a>
              </div>
              <p>Space the nodes and hyphen horizontally.</p>

            </div>
            
            <div class="content"><div class='highlight'><pre>        util.spaceHorizontally(contents, {
          <span class="hljs-attr">padding</span>: <span class="hljs-number">5</span>
        });
      });
  },

  setup() {</pre></div></div>
            
        </li>
        
        
        <li id="section-5">
            <div class="annotation">
              
              <div class="pilwrap ">
                <a class="pilcrow" href="#section-5">&#182;</a>
              </div>
              <p>The two nodes for the range. In <code>[a-z]</code> these would be
<a href="./literal.html">Literal</a> nodes for “a” and “z”.</p>

            </div>
            
            <div class="content"><div class='highlight'><pre>    <span class="hljs-keyword">this</span>.first = <span class="hljs-keyword">this</span>.properties.first;
    <span class="hljs-keyword">this</span>.last = <span class="hljs-keyword">this</span>.properties.last;</pre></div></div>
            
        </li>
        
        
        <li id="section-6">
            <div class="annotation">
              
              <div class="pilwrap ">
                <a class="pilcrow" href="#section-6">&#182;</a>
              </div>
              <p>Report invalid expression when extents of the range are out of order.</p>

            </div>
            
            <div class="content"><div class='highlight'><pre>    <span class="hljs-keyword">if</span> (<span class="hljs-keyword">this</span>.first.ordinal &gt; <span class="hljs-keyword">this</span>.last.ordinal) {
      <span class="hljs-keyword">throw</span> <span class="hljs-string">`Range out of order in character class: <span class="hljs-subst">${<span class="hljs-keyword">this</span>.textValue}</span>`</span>;
    }
  }
};</pre></div></div>
            
        </li>
        
    </ul>
  </div>
</body>
</html>
